package com.wyp.design.pattern.creational.singleton.threadlocal;

/**
 * @author: yipeng.wang01@hand-china.com-25490
 * @TIME: 2020/1/2/13:45
 **/
public class Test {
    public static void main(String[] args) {
        Thread t1 = new Thread(new T());
        Thread t2 = new Thread(new T());

        //在当前主线程中获取该threadLocal线程单例。
        System.out.println("main thread: " +ThreadLocalInstance.getInstance());
        System.out.println("main thread: " +ThreadLocalInstance.getInstance());
        System.out.println("main thread: " +ThreadLocalInstance.getInstance());
        System.out.println("main thread: " +ThreadLocalInstance.getInstance());
        System.out.println("main thread: " +ThreadLocalInstance.getInstance());
        System.out.println("main thread: " +ThreadLocalInstance.getInstance());

        t1.start();
        t2.start();
        System.out.println("end ");
    }
}
